home *** CD-ROM | disk | FTP | other *** search
- /*
- * ShowDia.rexx (Version 1.1 - 13 December 1993)
- * (Added Scrolling capabilities!)
- *
- * View assorted pictures on your Piccolo card with the Dia program.
- * This script is based on Alexander Pratsch his DO-Dia.rexx script.
- * Text display and (mouse) wait support added by Paul Kolenbrander.
- *
- * This program will load a picture into Dia and will display the filename
- * of this picture in the upperleft corner in a font and size specified by
- * the user. Also the user may choose to either specify a Delay time as a
- * Tooltype or use the left mousebutton to determine when the next picture
- * should be loaded. The scripts defaults to a 1 second wait period.
- *
- * Arguments: name - Path and filename of picture to view.
- * font - name of font to use, eg. magneto.font
- * (Do not forget the .font addition)
- * size - Size of font to use. If you specify a non-existing
- * font, the program will substitute and existing one.
- * wait - Delay to show the next picture in 50th of a second.
- * When the user enters 0, then this script will wait
- * for a press on that left mousebutton before showing
- * the next picture. (Default is 1 second wait.)
- *
- * Make sure font & size is specified if the wait parameter is to be used.
- * If you don't want text, just specify 0 0 x. Where x is the wait value.
- * That way the script won't show the filename, but it'll wait for you to
- * click the mouse. (if x is 0) Or delay the specified amount of time if x
- * is greater than 0.
- *
- * Newly added feature... When you select a delay period by mouse-click (delay = 0)
- * you can now scroll around pictures that are larger than the screen. All around
- * the screen are 25 pixel wide invisibale scroll bars. Click in the appropriate one
- * and the picture will scroll 25 pixels out of that direction... Click anywhere in
- * the picture outside those scrollbars and the next picture is loaded. Where you
- * can also scroll around in.
- *
- * NOTE: Scrolling only works when the loaded picture is LARGER than the screen it is
- * displayed in... And only those hidden parts can be scrolled into sight.
- *
- * Screen & Scroll Bar lay-out...
- *
- * +--------------------------------------+ -
- * | | Scroll Down | | | 25 pixels wide
- * |S |--------------------------------| S| -
- * |c | | c|
- * |r | | r|
- * |o | | o|
- * |l | Exit | l|
- * |l | Scroll | l|
- * | | Routine. | |
- * |R | | L|
- * |i | | e|
- * |g | | f|
- * |h | | t|
- * |t |--------------------------------| | -
- * | | Scroll Up | | | 25 pixels wide
- * +--------------------------------------+ -
- * |--| |--|
- * 25 pixels wide 25 pixels wide
- *
- *
- * - Installing this script into Directory-Opus.
- *
- * Call up the Directory Opus Configuration program.
- *
- * Make sure you specify 'AmigaDOS' and enter the below line in the string
- * gadget:
- *
- * rx s:ShowDia.rexx {f} [<fontname> <fontsize> <waitperiod>]
- *
- * where [....] are optional values. See the arguments discussion above.
- *
- * Example: rx:ShowDia.rexx {f} topaz.font 9 0
- *
- * Here the Topaz 9points font is used and the script waits until the left
- * mousebutton is pressed before showing the next file. (if any are left.)
- *
- * Make sure 'No filename quote', 'Reload each file' & 'Do all files' are
- * selected as options.
- *
- * For more info on installing tools in Directory Opus please consult it's
- * manual.
- *
- * Send suggestions and problemreports to: boinger@myamy.hacktic.nl
- * paulk@stack.urc.tue.nl
- *
- */
-
- /* Parse the arguments */
- PARSE ARG name font size wait
-
- IF font = 'font' | font = '' | font = 'FONT' THEN font = 0
- IF wait = 'wait' | wait = '' | wait = 'WAIT' THEN wait = 50
-
- IF size = 0 | size = 'size' | size = 'SIZE' THEN size = 8
-
- /* Set the ToolTypes. -- ATTN: Adjust to your configuration and liking -- */
- diaName = 'egs:Piccolo/Dia/Dia "SCREEN=PICOa:SVGA 800x600" DELAY='||wait||'
- DEPTH=16
- ZOOM=ON AUTOCLEAR=ON';
-
- /* We need the rexxsupport.library, so check if it's there */
- IF( ~SHOW( 'L', "rexxsupport.library" ) ) THEN DO
- IF( ~ADDLIB("rexxsupport.library", 0, -30, 0 )) THEN DO
- EXIT
- END
- END
-
- /* Now check if the specified font exists, and if the size is valid. */
- /* If an invalid font is specified, then use default topaz 8 */
-
- IF font ~=0 & font ~= "topaz.font" THEN DO
- IF EXISTS("Fonts:" || font) THEN DO
- tmp = POS(".font", font)
- IF tmp ~= 0 THEN DO
- fontname = DELSTR(font,tmp)
- IF ~EXISTS("Fonts:" || fontname || "/"size) THEN DO
- tmp=SHOWDIR("Fonts:" || fontname, 'f')
- size=STRIP(LEFT(tmp, 2))
- END
- END
- END
- ELSE DO
- fontname = "topaz.font"
- size = 8
- END
- END
-
-
- OPTIONS RESULTS
-
- Max_Seconds_To_Load = 60
- Flag = 0
-
- /* Check if Dia is already running. If not, then start it up. */
- TIME( 'R' )
- DO WHILE (TIME( 'E' ) < Max_Seconds_To_Load) & (POS( 'rainbow', SHOW( 'Ports' ) ) = 0)
- IF Flag = 0 THEN DO
- /* Set whatever command line arguments you want. */
- ADDRESS COMMAND 'run <nil: >nil: ' || diaName;
- Flag = 1
- END
- ADDRESS COMMAND 'WAIT 1'
- END
-
- IF POS( 'rainbow', SHOW( 'Ports' ) ) = 0 THEN
- DO
- SAY "Failed!"
- EXIT
- END
- ELSE DO
- /* Now we load the picture */
- path=PRAGMA('D','')
- /* check if path is given, otherwise add current path to name
- */
- if ~ ((VERIFY('/',name)==0) | (VERIFY(':',name)==0)) THEN DO
- name=path || '/' || name
- END
-
- IF EXISTS(name) THEN DO /* existing File ? */
- address "rainbow";
-
- SAY "loading " || name || "..."
- AUTOCLEAR ON
- SCROLLING ON
- COLOR 0 0 0
- BCOLOR 170 170 170
- OPEN name /* If yes, load Picture */
- IF font ~= 0 THEN DO /* Display Filename? */
- DMODE 1
- SFNAME font
- SETFONT size 0
- MOVE 2 2
- TEXT name
- END
- If wait = 0 THEN CALL Scrollem /* Wait for mouseclick? */
- END
- ELSE DO
- say name || " doesn't exist."
- END
- END
-
- EXIT
-
- /* T-t-t-that's all f-f-f-folks! Y'awl come back now, ya hear. */
- /*---------------------------- Subroutine Section ---------------------------*/
- Scrollem:
- /* In this subroutine we allow the user to scroll around the picture if it is */
- /* larger than the screen. */
-
- OPTIONS RESULTS
- GET_SW
- scx = result
- GET_SH
- scy = result
- GET_W
- picx = result
- GET_H
- picy = result
-
- /*
- debug info... Uncomment if you like to see what's going on.
- say 'Screen Width : ' || scx
- say 'Screen Height: ' || scy
- say 'Picture Width: ' || picx
- say 'PictureHeight: ' || picy
- end of debug info
- */
-
- einde = 0
- SCROLLING ON
- xpos = 0
- ypos = 0
- DO WHILE einde = 0
- WAITMOUSE /* Wait for mouseclick? */
- /* If clicked, we get the mouse x and y coordinate */
-
- OPTIONS RESULTS
- GET_MX
- mx = result
- GET_MY
- my = result
- /*
- some more debug info...
- say 'Mouse X pos. : ' || mx
- say 'Mouse Y pos. : ' || my
- say 'Pict. X pos : ' || xpos
- say 'Pict. Y pos : ' || ypos
- end the end of it
- */
-
- /* Clicked in the rightmost 25 pixels so we scroll to the left */
- IF (scx - mx) <= 25 THEN DO
- xpos = xpos + 25
- IF xpos > (picx - scx) THEN xpos = picx - scx
- SCROLLTO xpos ypos /* Scroll Right */
- END
-
- /* Clicked in the leftmost 25 pixels, so we scroll to the right */
- IF mx <= 25 THEN DO
- xpos = xpos - 25
- IF xpos < 0 THEN xpos = 0
- SCROLLTO xpos ypos /* Scroll Left */
- END
-
- /* Clicked in the uppermost 25 pixels, so we scroll down */
- IF my <= 25 & mx > 25 & (scx - mx) > 25 THEN DO
- ypos = ypos - 25
- IF ypos < 0 THEN ypos = 0
- SCROLLTO xpos ypos /* Scroll Down */
- END
-
- /* Clicked in the lowermost 25 pixels, so we scroll up */
- IF (scy - my) <= 25 & mx > 25 & (scx - mx) > 25 THEN DO
- ypos = ypos + 25
- IF ypos > (picy - scy) THEN ypos = picy - scy
- SCROLLTO xpos ypos /* Scroll Up */
- END
-
- /* Clicked out of the scroll boxes. Means we exit this scroll routine */
- IF (scx - mx) > 25 & mx > 25 & my > 25 & (scy - my) > 25 THEN
- einde = 1 /* Exit the scroll routine */
- END
-
- RETURN
-